<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $frase = new Application_Model_Frases();
        $select = $frase->select()->limit($this->_getParam("frasesize"))->order(new Zend_Db_Expr('RAND()'));
        //die($select->__toString());
        $this->view->frases = $frase->fetchAll($select);
    }

    public function submitabsurdoAction()
    {
        $request = $this->_request;
        $form = new Application_Form_EnvioAbsurdo();

        if ($request->isPost())
        {
            if ($form->isValid($request->getPost()))
            {
                $valoresPost = $request->getPost();

                $valores = array();
                $valores['autor'] = $valoresPost['autor'];
                $valores['autor_email'] = $valoresPost['autor_email'];
                $valores['frase'] = $valoresPost['frase'];

                $frase = new Application_Model_Frases();
                $id = $frase->insert($valores);
            }
        }

        $this->view->form = $form;
    }

}